<?php include './application/views/common/zhs_header.php';?>
<div class="newtitle-box">
  <div class="newtitle w">
    <span class="invlist_title">您现在的位置：<a href="/">首页</a>><a class="red" href="#">找回密码</a></span>
  </div>
  </div>
  <div class="login_box w">
    <div class="login_bd">
 <form id="my_form">
		<a style="float:left;" href="javascript:;">找回方式：</a><span style="float:left;">
		<input type="radio" style="float:left; margin:3px 6px 0;" name="typer" value="email" onclick="typerfindpsd(this);" checked ><span style="float:left;">邮箱找回</span>
		<input type="radio" style="float:left; margin:3px 6px 0;" name="typer" value="phone" onclick="typerfindpsd(this);" ><span style="float:left;">手机找回</span></span>
			<ul style="clear:both;">
				<li>会员昵称(<em style="color:red;">默认是手机号码</em>)：<dt><input class="inptl_1" name="username" id="username" type="text" value="请输入会员昵称" onfocus="clearText(this);" onblur="setText(this,'请输入会员昵称');"></dt></li>
				<li id="ul1" style="display:block">邮箱<dt><input class="inptl_1" name="email" id="email" type="text" value="请输入邮箱" onfocus="clearText(this);" onblur="setText(this,'请输入邮箱');"></dt></li>
				<li id="ul2" style="display:none">手机验证码：<dt><input class="inptl_1" name="ca_key" id="ca_key" type="text" value="请输入手机验证码" onfocus="clearText(this);" onblur="setText(this,'请输入手机验证码');"><a href="javascript:;" class="regbtn0" onclick="phoneSubmit();" id="phone_code">获取验证码</a></dt></li>
				<li>验证码：<dt><input  class="inptl_1" type="text" id="captcha" name="captcha" maxlength="4"></input></dt><dt><img src="/yanzheng/index/" id="imgCode" onclick="changeImage();" style="cursor:pointer;padding:0px;border: 0; margin:12px 0 0 10px;"/></dt></li>
				<li>&nbsp;<dt><input style="cursor:pointer; margin:0;" class="little_button" id="btnSubmit" type="button" value="马上找回" onclick="toSubmit();"></dt></li>
				<li>&nbsp;<dt>还没有加入<?php echo CON_PLATFORMNAME;?>？<a href="/reg.html">免费注册</a></dt></li>
			</ul>
		</form>
    
 <script type="text/javascript">
function clearText(input){
	if(input.value=='请输入会员昵称' || input.value=='请输入邮箱'|| input.value=='请输入手机号'|| input.value=='请输入手机验证码'){
		input.value="";
	}
}

function setText(input,txt){
	if(input.value==''){
		input.value=txt;
	}
}
function typerfindpsd(obj){
	var ul1=document.getElementById('ul1');
	var ul2=document.getElementById('ul2');
	if(obj.value == 'email') {
		ul1.style.display = 'block';
		ul2.style.display = 'none';
	}
	else if(obj.value  == 'phone'){
		ul1.style.display = 'none';
		ul2.style.display = 'block';
	}
}

function toSubmit(){
	var options = {
		url : '/password/zhs_forget',
		beforeSubmit:  checkForm,
		dataType: "json",
		type:"post",
		success : function(ret) {
			$('#dialog').dialog({
				modal:true,
				title:'系统提示',
				buttons:{"确定":function(){$(this).dialog("close");}},
				close: function() {
					document.getElementById("imgCode").src = "/yanzheng/index/?" + Math.random();
					if(ret.info == '1') window.location="/login";
				}
			}); 
			$("#msg").html(ret.msg);
		}
	};
	$("#my_form").ajaxSubmit(options);
	return false;
}

function checkForm(){
	//return true;
	var err = '';
	if($('#username').val()==''||$('#username').val()=='请输入会员昵称'){
		err = '请输入会员昵称';
	}else if($('#captcha').val()==''){
		err = '请输入验证码';
	}
	if(err==''){
		return true;
	}else{
		$('#dialog').dialog({
			modal:true,
			title:'系统提示',
			buttons:{"确定":function(){$(this).dialog("close");}},
			close: function() {
				document.getElementById("imgCode").src = "/yanzheng/index/?" + Math.random();
			}
		}); 
		$("#msg").html(err);
		return false;
	}
}
function phoneSubmit(){
	if($('#username').val()=='' || $("#username").val() == "请输入会员昵称"){
		$('#dialog').dialog({
			modal:true, //蒙层（弹出会影响页面大小）
			title:'系统提示',
			buttons:{"确定":function(){$(this).dialog("close");}},
			close: function() {
			}
		}); 
		$("#msg").html("请输入会员昵称");
		$("#username").focus();
		return false;
	}else{
		$("#phone_code").html('处理中，请等待');
		$.ajax({
			type: "post",
			url: "/reg/sendsms/",
			data: "username="+$("#username").val(),
			success: function(ret){
				if(ret.info == 1){
					alert('发送成功,请接收 ');
				}else{
					alert(ret.msg);
				}
				setTimeout(function(){
					$("#phone_code").html('重新获取验证码');
					},3000);
			},
			dataType: "json"
		});	
	}
	
}

</script>
</div>
</div> 
<?php include './application/views/common/zhs_footer.php';?>
<?php include './application/views/common/zhs_right.php';?>

